<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>当前时间</title>
    <script>
        function loadTime(){
            setInterval(function(){
                let date = new Date();
                document.getElementById("s1").innerHTML = date.getFullYear()+"年"+fn(date.getMonth()+1)+"月"+fn(date.getDate())+"日"+fn(date.getHours())+":"+fn(date.getMinutes())+":"+fn(date.getSeconds());
            },100);
        }
        function fn(s){
            s = "0"+s;
            return s.substring(s.length-2);
        }
    </script>
</head>
<body onload="loadTime()">
<!--
    在浏览器中展现当前的时间
    时间格式为:yyyy年MM月dd日 HH:mm:ss
    且该时间会自动走动
-->
当前时间:<span id="s1"></span>
</body>
</html>